package com.yycx.module.bus.provider.handler.cbreturn;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.mybatis.interceptor.GetInterceptor;
import com.yycx.common.mybatis.query.CriteriaQuery;
import com.yycx.module.bus.client.entity.BusDept;
import com.yycx.module.bus.client.entity.BusPayment;
import com.yycx.module.bus.client.entity.BusSaleman;
import com.yycx.module.bus.client.entity.BusSalemanBank;
import com.yycx.module.bus.provider.service.BusDeptService;
import com.yycx.module.bus.provider.service.BusSalemanBankService;
import com.yycx.module.bus.provider.service.BusSalemanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 退保证金单详情扩展
 *
 * @author zyf
 */
@Component("cbReturnPaymentGetHandler")
public class CbReturnPaymentGetHandler implements GetInterceptor {

    @Autowired
    private BusDeptService deptService;

    @Autowired
    private BusSalemanService salemanService;

    @Autowired
    private BusSalemanBankService salemanBankService;

    @Override
    public void prepare(CriteriaQuery cq, EntityMap entityMap) {
        cq.select(BusPayment.class, "*");
    }

    @Override
    public void complete(CriteriaQuery cq, EntityMap map) {
        Long deptId = map.getLong("deptId");
        Long bankId=map.getLong("bankId");
        BusDept dept = deptService.getById(deptId);
        BusSaleman deptSaleMan = salemanService.getById(dept.getSalemanId());
        map.put("deptSaleManName",deptSaleMan.getSaleManName());
        BusSalemanBank salemanBank=salemanBankService.getById(bankId);
        Long saleManId=salemanBank.getSaleManId();
        BusSaleman saleman=salemanService.getById(saleManId);
        map.put("saleManName",salemanBank.getSaleManName());
        map.put("bankName",salemanBank.getBankName());
        map.put("bankNo",salemanBank.getBankNo());
    }
}
